const menus = {
  only: [{
    id: 'home',
    path: '/home',
    name: '首页'
  }],
  // ADMIN: [{
  //     id: 'home',
  //     path: '/home',
  //     name: '首页'
  //   },
  //   {
  //     id: 'apply_1',
  //     path: '/apply/apply_form',
  //     name: '申请服务'
  //   },
  //   {
  //     id: 'apply-2',
  //     path: '/apply/my_form',
  //     name: '待审批'
  //   },
  //   {
  //     id: 'apply-5',
  //     path: '/apply/my_handle',
  //     name: '我经手的'
  //   },
  //   {
  //     id: 'apply-4',
  //     path: '/apply/examined_form',
  //     name: '已审批'
  //   },
  //   {
  //     id: 'apply-3',
  //     path: '/apply/search_form',
  //     name: '查询'
  //   }
  // ],
  // examine: [{
  //     id: 'home',
  //     path: '/home',
  //     name: '首页'
  //   },
  //   {
  //     id: 'apply-2',
  //     path: '/apply/my_form',
  //     name: '待审批'
  //   },
  //   {
  //     id: 'apply-5',
  //     path: '/apply/my_handle',
  //     name: '我经手的'
  //   },
  //   {
  //     id: 'apply-4',
  //     path: '/apply/examined_form',
  //     name: '已审批'
  //   },
  //   {
  //     id: 'apply-3',
  //     path: '/apply/search_form',
  //     name: '查询'
  //   }
  // ],
  // ordinary: [{
  //     id: 'home',
  //     path: '/home',
  //     name: '首页'
  //   },
  //   {
  //     id: 'apply-1',
  //     path: '/apply/apply_form',
  //     name: '申请服务'
  //   },
  //   {
  //     id: 'apply-2',
  //     path: '/apply/my_form',
  //     name: '待审批'
  //   },

  //   {
  //     id: 'apply-4',
  //     path: '/apply/examined_form',
  //     name: '已审批'
  //   },
  //   {
  //     id: 'apply-3',
  //     path: '/apply/search_form',
  //     name: '查询'
  //   }
  // ],

  // home: [
  //   'CITY_GOVERNMENT_ENTERPRISE_SERVICE_AUDITOR',
  //   'LARGE_ORDER_SERVICE_MANAGER',
  //   'CITY_GOVERNMENT_ENTERPRISE_LEADERSHIP_AUDITOR',
  //   'ADMIN',
  //   'SERVICE_CARD_MANAGER',
  //   'CITY_ZQ_DEPARTMENT_AUDITOR',
  //   'CITY_COMPREHENSIVE_RECONCILIATION_AUDITOR',
  //   'GOLDEN_SERVICE_OBSERVER',
  //   'BIZ_HANDLE_CENTER_AUDITOR',
  //   'AREA_SUB_MANAGER_AUDITOR',
  //   'GOLDEN_SERVICE_AUDITOR',
  //   'CITY_COMPREHENSIVE_SALES_DISCOUNT_MUTUAL_EXCLUSIVE_AUDITOR',
  //   'CUSTOMER_MANAGER_TEMP_ADDER'
  // ],
  // apply_1: [
  //   'ADMIN',
  //   'GOLDEN_SERVICE_AUDITOR'
  // ],
  // apply_2: [
  //   'CITY_GOVERNMENT_ENTERPRISE_SERVICE_AUDITOR',
  //   'LARGE_ORDER_SERVICE_MANAGER',
  //   'CITY_GOVERNMENT_ENTERPRISE_LEADERSHIP_AUDITOR',
  //   'ADMIN',
  //   'SERVICE_CARD_MANAGER',
  //   'CITY_ZQ_DEPARTMENT_AUDITOR',
  //   'CITY_COMPREHENSIVE_RECONCILIATION_AUDITOR',
  //   'GOLDEN_SERVICE_OBSERVER',
  //   'BIZ_HANDLE_CENTER_AUDITOR',
  //   'AREA_SUB_MANAGER_AUDITOR',
  //   'GOLDEN_SERVICE_AUDITOR',
  //   'CITY_COMPREHENSIVE_SALES_DISCOUNT_MUTUAL_EXCLUSIVE_AUDITOR'
  // ],
  // apply_5: [
  //   'CITY_GOVERNMENT_ENTERPRISE_SERVICE_AUDITOR',
  //   'LARGE_ORDER_SERVICE_MANAGER',
  //   'CITY_GOVERNMENT_ENTERPRISE_LEADERSHIP_AUDITOR',
  //   'ADMIN',
  //   'SERVICE_CARD_MANAGER',
  //   'CITY_ZQ_DEPARTMENT_AUDITOR',
  //   'CITY_COMPREHENSIVE_RECONCILIATION_AUDITOR',
  //   'GOLDEN_SERVICE_OBSERVER',
  //   'BIZ_HANDLE_CENTER_AUDITOR',
  //   'AREA_SUB_MANAGER_AUDITOR',
  //   'CITY_COMPREHENSIVE_SALES_DISCOUNT_MUTUAL_EXCLUSIVE_AUDITOR'
  // ],
  // apply_4: [
  //   'CITY_GOVERNMENT_ENTERPRISE_SERVICE_AUDITOR',
  //   'LARGE_ORDER_SERVICE_MANAGER',
  //   'CITY_GOVERNMENT_ENTERPRISE_LEADERSHIP_AUDITOR',
  //   'ADMIN',
  //   'SERVICE_CARD_MANAGER',
  //   'CITY_ZQ_DEPARTMENT_AUDITOR',
  //   'CITY_COMPREHENSIVE_RECONCILIATION_AUDITOR',
  //   'GOLDEN_SERVICE_OBSERVER',
  //   'BIZ_HANDLE_CENTER_AUDITOR',
  //   'AREA_SUB_MANAGER_AUDITOR',
  //   'GOLDEN_SERVICE_AUDITOR',
  //   'CITY_COMPREHENSIVE_SALES_DISCOUNT_MUTUAL_EXCLUSIVE_AUDITOR'
  // ],
  // apply_3: [
  //   'CITY_GOVERNMENT_ENTERPRISE_SERVICE_AUDITOR',
  //   'LARGE_ORDER_SERVICE_MANAGER',
  //   'CITY_GOVERNMENT_ENTERPRISE_LEADERSHIP_AUDITOR',
  //   'ADMIN',
  //   'SERVICE_CARD_MANAGER',
  //   'CITY_ZQ_DEPARTMENT_AUDITOR',
  //   'CITY_COMPREHENSIVE_RECONCILIATION_AUDITOR',
  //   'GOLDEN_SERVICE_OBSERVER',
  //   'BIZ_HANDLE_CENTER_AUDITOR',
  //   'AREA_SUB_MANAGER_AUDITOR',
  //   'GOLDEN_SERVICE_AUDITOR',
  //   'CITY_COMPREHENSIVE_SALES_DISCOUNT_MUTUAL_EXCLUSIVE_AUDITOR'
  // ],
  nav: [

    {
      id: 'home',
      path: '/home',
      name: '首页',
      type: '0',
    },
    // {
    //   id: 'apply_1',
    //   path: '/apply/apply_form',
    //   name: '原金牌服务申请'
    // },
    {
      id: 'apply_6',
      path: '/greenCard',
      name: '绿卡申请',
      type: '1'
    },
    {
      id: 'apply_8',
      path: '/largeOrderDiscount',
      name: '大单服务',
      type: '1'
    },
    {
      id: 'apply_1',
      path: '/serviceCard',
      name: '服务卡',
      type: '1',
      // children: [{
      //   id: 'apply_1',
      //   path: '/apply/apply_form',
      //   name: '原金牌服务申请'
      // }, {
      //   id: 'apply_6',
      //   path: '/apply/apply_card',
      //   name: '绿卡申请'
      // }]
    },
    // {
    //   id: 'apply_6',
    //   path: '/apply/apply_card',
    //   name: '绿卡申请'
    // },
    {
      id: 'apply_2',
      path: '/pendingApproval',
      name: '待审批',
      type: '2'
    },
    {
      id: 'apply_5',
      path: '/myHandled',
      name: '我经手的',
      type: '2'
    },
    {
      id: 'apply_4',
      path: '/Approved',
      name: '已审批',
      type: '2'
    },
    // {
    //   id: 'apply_7',
    //   path: '/apply/soon_invalid',
    //   name: '一件续包'
    // },
    {
      id: 'apply_3',
      path: '/apply/search_form',
      name: '查询',
      type: '3'
    }
  ],
  // GREEN_CARD_CITY_GOVERNMENT_ENTERPRISE_SERVICE_AUDITOR // 绿卡
  role: [{
    home: [
      'CITY_GOVERNMENT_ENTERPRISE_SERVICE_AUDITOR',
      'LARGE_ORDER_SERVICE_MANAGER',
      'GREEN_CARD_CITY_GOVERNMENT_ENTERPRISE_LEADERSHIP_AUDITOR',
      'CITY_GOVERNMENT_ENTERPRISE_LEADERSHIP_AUDITOR',
      'ADMIN',
      'SERVICE_CARD_MANAGER',
      'CITY_ZQ_DEPARTMENT_AUDITOR',
      'CITY_COMPREHENSIVE_RECONCILIATION_AUDITOR',
      'GOLDEN_SERVICE_OBSERVER',
      'BIZ_HANDLE_CENTER_AUDITOR',
      'AREA_SUB_MANAGER_AUDITOR',
      'GOLDEN_SERVICE_AUDITOR',
      'CITY_COMPREHENSIVE_SALES_DISCOUNT_MUTUAL_EXCLUSIVE_AUDITOR',
      'CUSTOMER_MANAGER_TEMP_ADDER',
      'CUSTOM_MANAGER',
      'GREEN_CARD_CITY_GOVERNMENT_ENTERPRISE_SERVICE_AUDITOR',
      'GREEN_CARD_SERVICE_MANAGER'
    ],
    apply_1: [
      'ADMIN',
      'CUSTOM_MANAGER',
      'GREEN_CARD_CITY_GOVERNMENT_ENTERPRISE_SERVICE_AUDITOR'
    ],
    apply_2: [
      'CITY_GOVERNMENT_ENTERPRISE_SERVICE_AUDITOR',
      'LARGE_ORDER_SERVICE_MANAGER',
      'GREEN_CARD_CITY_GOVERNMENT_ENTERPRISE_LEADERSHIP_AUDITOR',
      'CITY_GOVERNMENT_ENTERPRISE_LEADERSHIP_AUDITOR',
      'ADMIN',
      'SERVICE_CARD_MANAGER',
      'CITY_ZQ_DEPARTMENT_AUDITOR',
      'CITY_COMPREHENSIVE_RECONCILIATION_AUDITOR',
      'GOLDEN_SERVICE_OBSERVER',
      'BIZ_HANDLE_CENTER_AUDITOR',
      'AREA_SUB_MANAGER_AUDITOR',
      'GOLDEN_SERVICE_AUDITOR',
      'CITY_COMPREHENSIVE_SALES_DISCOUNT_MUTUAL_EXCLUSIVE_AUDITOR',
      'CUSTOM_MANAGER',
      'GREEN_CARD_CITY_GOVERNMENT_ENTERPRISE_SERVICE_AUDITOR',
      'GREEN_CARD_SERVICE_MANAGER'
    ],
    apply_5: [
      'CITY_GOVERNMENT_ENTERPRISE_SERVICE_AUDITOR',
      'LARGE_ORDER_SERVICE_MANAGER',
      'GREEN_CARD_CITY_GOVERNMENT_ENTERPRISE_LEADERSHIP_AUDITOR',
      'CITY_GOVERNMENT_ENTERPRISE_LEADERSHIP_AUDITOR',
      'ADMIN',
      'SERVICE_CARD_MANAGER',
      'CITY_ZQ_DEPARTMENT_AUDITOR',
      'CITY_COMPREHENSIVE_RECONCILIATION_AUDITOR',
      'GOLDEN_SERVICE_OBSERVER',
      'BIZ_HANDLE_CENTER_AUDITOR',
      'AREA_SUB_MANAGER_AUDITOR',
      'CITY_COMPREHENSIVE_SALES_DISCOUNT_MUTUAL_EXCLUSIVE_AUDITOR',
      'GOLDEN_SERVICE_AUDITOR',
      'GREEN_CARD_SERVICE_MANAGER'
    ],
    apply_4: [
      'CITY_GOVERNMENT_ENTERPRISE_SERVICE_AUDITOR',
      'LARGE_ORDER_SERVICE_MANAGER',
      'GREEN_CARD_CITY_GOVERNMENT_ENTERPRISE_LEADERSHIP_AUDITOR',
      'CITY_GOVERNMENT_ENTERPRISE_LEADERSHIP_AUDITOR',
      'ADMIN',
      'SERVICE_CARD_MANAGER',
      'CITY_ZQ_DEPARTMENT_AUDITOR',
      'CITY_COMPREHENSIVE_RECONCILIATION_AUDITOR',
      'GOLDEN_SERVICE_OBSERVER',
      'BIZ_HANDLE_CENTER_AUDITOR',
      'AREA_SUB_MANAGER_AUDITOR',
      'GOLDEN_SERVICE_AUDITOR',
      'CITY_COMPREHENSIVE_SALES_DISCOUNT_MUTUAL_EXCLUSIVE_AUDITOR',
      'CUSTOM_MANAGER',
      'GREEN_CARD_CITY_GOVERNMENT_ENTERPRISE_SERVICE_AUDITOR',
      'GREEN_CARD_SERVICE_MANAGER'
    ],
    apply_3: [
      'CITY_GOVERNMENT_ENTERPRISE_SERVICE_AUDITOR',
      'LARGE_ORDER_SERVICE_MANAGER',
      'GREEN_CARD_CITY_GOVERNMENT_ENTERPRISE_LEADERSHIP_AUDITOR',
      'CITY_GOVERNMENT_ENTERPRISE_LEADERSHIP_AUDITOR',
      'ADMIN',
      'SERVICE_CARD_MANAGER',
      'CITY_ZQ_DEPARTMENT_AUDITOR',
      'CITY_COMPREHENSIVE_RECONCILIATION_AUDITOR',
      'GOLDEN_SERVICE_OBSERVER',
      'BIZ_HANDLE_CENTER_AUDITOR',
      'AREA_SUB_MANAGER_AUDITOR',
      'GOLDEN_SERVICE_AUDITOR',
      'CITY_COMPREHENSIVE_SALES_DISCOUNT_MUTUAL_EXCLUSIVE_AUDITOR',
      'CUSTOM_MANAGER',
      'GREEN_CARD_CITY_GOVERNMENT_ENTERPRISE_SERVICE_AUDITOR',
      'GREEN_CARD_SERVICE_MANAGER'
    ],
    apply_6: [
      'ADMIN',
      'CUSTOM_MANAGER',
      'GREEN_CARD_CITY_GOVERNMENT_ENTERPRISE_SERVICE_AUDITOR'
    ],
    apply_7: [
      'ADMIN',
      'CUSTOM_MANAGER',
      'GREEN_CARD_CITY_GOVERNMENT_ENTERPRISE_SERVICE_AUDITOR'
    ],
    apply_8: [
      'ADMIN',
      'CUSTOM_MANAGER',
      'GREEN_CARD_CITY_GOVERNMENT_ENTERPRISE_SERVICE_AUDITOR'
    ]
  }]

}

export function listMenus(myRole) {
  const arr = []
  const roleLIst = []

  if (Object.prototype.toString.call(myRole) === '[object Array]') {
    for (const key in menus['role'][0]) {
      myRole.map((item) => {
        if (menus['role'][0][key].indexOf(item.name) !== -1) {
          if (arr.indexOf(key) !== -1) return
          arr.push(key)
        }
      })
    }
    menus['nav'].map((res) => {
      if (arr.indexOf(res.id) !== -1) {
        roleLIst.push(res)
      }
    })
    return Promise.resolve(roleLIst)
  } else {
    return Promise.resolve(roleLIst)
  }

  // return Promise.resolve(menus['ADMIN'])
}
